extends Control
@onready var new_game_buttton: Button = $VBoxContainer/newGameButtton
@onready var continue_button: Button = $VBoxContainer/continueButton
@onready var setting_button: Button = $VBoxContainer/settingButton
@onready var quit_button: Button = $VBoxContainer/quitButton
@onready var boat: Sprite2D = $boat

var button_array : Array[Button]

var index: int = 0:
	set(v):
		
		if v > 3:
			index = 0
		elif v < 0:
			index = 3
		else:
			index = v
		
		boat.global_position.y = button_array[index].position.y

func _ready() -> void:
	button_array = [new_game_buttton,continue_button,setting_button,quit_button]
	
func _unhandled_input(event: InputEvent) -> void:
	if event.is_action_pressed("move_down"):
		index += 1
		
	if event.is_action_pressed("move_up"):
		index -= 1
	
	if event.is_action_pressed("interact"):
		if index == 0:
			get_tree().change_scene_to_file("res://scenes/main.tscn")
		if index == 3:
			get_tree().quit()
		
	
